/**
 业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            adminRoomDetailInfo: {
                viewOwnerFlag: '',
                roomId: "",
                floorNum: '',
                unitNum: '',
                roomNum: '',
                layer: "",
                builtUpArea: "",
                roomSubTypeName: "",
                stateName: "",
                roomArea: "",
                roomRent: "",
                startTime: "",
                endTime: "",
                _currentTab: 'aRoomDetailOwner',
                remark:'',
                ownerId:'',
                ownerName:'',
                link:'',
                communityId:'',
                communityName:''
            }
        },
        _initMethod: function () {
            $that.adminRoomDetailInfo.roomId = vc.getParam('roomId');
            if (!vc.notNull($that.adminRoomDetailInfo.roomId)) {
                return;
            }
            let _currentTab = vc.getParam('currentTab');
            if (_currentTab) {
                $that.adminRoomDetailInfo._currentTab = _currentTab;
            }
            $that._loadAdminRoomInfo();
           
        },
        _initEvent: function () {
            vc.on('adminRoomDetail', 'listOwnerData', function (_info) {
                $that._loadOwnerInfo();
                $that.changeTab($that.adminRoomDetailInfo._currentTab);
            });
        },
        methods: {
            _loadAdminRoomInfo: function () {
                let param = {
                    params: {
                        roomId: $that.adminRoomDetailInfo.roomId,
                        page: 1,
                        row: 1,
                    }
                }
                //发送get请求
                vc.http.apiGet('/room.queryAdminRoom',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.adminRoomDetailInfo);
                        $that.changeTab($that.adminRoomDetailInfo._currentTab);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.adminRoomDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    roomId: $that.adminRoomDetailInfo.roomId,
                    ownerId: $that.adminRoomDetailInfo.ownerId,
                    ownerName: $that.adminRoomDetailInfo.ownerName,
                    link: $that.adminRoomDetailInfo.link,
                })
            },
            _openEditOwnerDetailModel: function () {
                vc.emit('editOwner', 'openEditOwnerModal', $that.adminRoomDetailInfo);
            },
        }
    });
})(window.vc);